package doyyin;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;

@Data
public class getFollowing implements Serializable {
    //https://www-hj.douyin.com/aweme/v1/web/user/following/list/抖音关注列表
    static String path = "E:\\tmp\\following.txt";
    public static void main(String[] args) {
        String content =null;
        try {
            content = FileUtils.readFileToString(new File(path), "UTF-8");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        JSONObject jsonObject = JSONObject.parseObject(content);
        JSONArray followings = jsonObject.getJSONArray("followings");
        for (int i = 0; i < followings.size(); i++) {
            JSONObject jsonObject1 = followings.getJSONObject(i);
            String sec_uid = jsonObject1.getString("sec_uid");
            String nickname = jsonObject1.getString("nickname");
            System.out.println(i+"   "+sec_uid+" "+nickname);
            StrUtil.format("https://www.douyin.com/user/{}?from_tab_name=main#{}",
                    sec_uid,
                    nickname
                    );
        }
    }
}
